
function getSelect(value,obj){
       var id = value;
           $.ajax({
        url: $.getEnvUrl()+"/index.php?m=Admin&c=WechatEnt&a=getDeptById&token=ofanap1448334221&id=" + id,
        type: "GET",

        error: function () {
            alert('Error loading XML document');
        },
        success: function (data, status) { //如果调用php成功  
            // var data = JSON.parse(data);
            console.log(data);
            if (data.status == 0) {
                obj.attr('id','isvalue');
            } else {
                obj.next().remove();
                var str = "<select  style='margin-top:10px' class='select_change form-control'><option value=''>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    str += '<option class="" value='+"'"+data[i].id+"'"+'>'+data[i].name+'</option>';
                }
                str += "</select>";
                $("#depart").append(str);
            }
        }
    });
}

$(document).on("change",".select_change",function(){
        var id = $(this).val();
    if(id==false){
        return false;
    }
     getSelect(id,$(this));
    // var islast = $('#golast').val();
    // alert(islast);
    // if(islast==1)
    //         $(this).attr('isLast',1);
});

function sleep(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)    return;
    }
}